﻿using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Odin.Base.IO {
    public class Console {
        public static List<String> events = new List<String>();
        private static TextWriter tw;

        static Console() {
            tw = new StreamWriter("log.txt");

            tw.WriteLine("New Log Entry: " + DateTime.Now.ToString());
        }

        public static void Log(String eventType, String message) {
            String result = "";
            result += DateTime.Now.ToString() + ": ";
            result += eventType + ", ";
            result += message;

            events.Add(result);
            tw.WriteLine(result);
        }

        public static void ShowLog() {
#if (DEBUG)
            for (int i = 0; i < events.Count; i++) {
                System.Console.WriteLine(events[i]);
            }
#endif
            // Default logging
        }

        public static void SaveLog() {
            tw.WriteLine("END OF LOG: " + DateTime.Now.ToString());
            tw.WriteLine();
            tw.Flush();
            tw.Close();
        }
    }
}
